interface Component{
    void Operation();//装饰函数，装饰接口
}
class ConcreteComponent implements Component{
    public void Operation(){
        System.out.println("赤裸身体");
    }
}
class Decorator implements Component{
    private Component component;//构建装饰链
    public void setComponent(Component component){
//        指向被装饰的对象
        this.component=component;
    }
    public void Operation(){
        if (this.component!=null){//保持之前的装饰，沿着装饰链找到最初的被装饰的对象，然后开始装饰
            this.component.Operation();//让下一个装饰对象进行装饰
        }
    }
}
class ConcreteDecoratorA extends Decorator{
    public void Operation(){
        //先进行之前的装饰，再添加自己的装饰效果
        super.Operation();
        System.out.println("穿长裤");
    }
}
class ConcreteDecoratorB extends Decorator{
    public void Operation(){
        //先进行之前的装饰，再添加自己的装饰效果
        super.Operation();
        System.out.println("穿短裤");
    }
}
public class Test {
    public static void main(String[] args) {
        Component c=new ConcreteComponent();
        Decorator d1=new ConcreteDecoratorA();
        Decorator d2=new ConcreteDecoratorB();

//        构建装饰链
        d1.setComponent(c);
        d2.setComponent(d1);
//        开始装饰
        d2.Operation();
    }
}
